package com.yc.test;

import com.yc.bean.Resfood;
import com.yc.commons.DBHelper;

import java.lang.reflect.InvocationTargetException;
import java.util.List;
import java.util.Map;

/**
 * @author zwei
 * @create 2024-06-16 17:42
 */
public class test {
    public static void main(String[] args) throws InvocationTargetException, InstantiationException, IllegalAccessException {
        List<Resfood>food=findByPage(1,5,"realprice","asc");
        System.out.println(food);
    }
    protected static List<Resfood>findByPage(int pageno, int pagesize, String sortby, String sort) throws InvocationTargetException, InstantiationException, IllegalAccessException {
        String sql = "SELECT * FROM resfood ORDER BY \" + sortby + \" \" + sort + \" LIMIT ?, ?";

        DBHelper dbHelper = new DBHelper();
        int start = (pageno - 1) * pagesize;
        List<Resfood> list = dbHelper.select(Resfood.class, sql, start, pagesize);

        return list;
    }
}
